home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 1993 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.5 KB

  1. Path: mail2news.demon.co.uk!trumpton.demon.co.uk
  2. From: Steve Clarke <steve@trumpton.demon.co.uk>
  3. Newsgroups: comp.lang.c++
  4. Subject: Question:  Share and unlink
  5. Date: Sun, 14 Jan 1996 22:17:40 GMT
  6. Organization: Trumpton Fire Station
  7. Message-ID: <526557702wnr@trumpton.demon.co.uk>
  8. Reply-To: steve@trumpton.demon.co.uk
  9. X-NNTP-Posting-Host: trumpton.demon.co.uk
  10. X-Broken-Date: Sun, 14 Jan 1996 22:04:01 gmt0bst1
  11. X-Newsreader: Newswin Alpha 0.9
  12. X-Mail2News-Path: relay-4.mail.demon.net!post.demon.co.uk!trumpton.demon.co.uk
  13.  
  14.  
  15. I am using BC4.51, and am attempting to write a function to remove a file, with an 
  16. share_unlink() function for use in a DOS C++ application.
  17.  
  18. The file(s) I am trying to remove are opened regularly by other programs, and the 
  19. function I am trying to write is:
  20.  
  21. share_unlink(filename, delay)
  22.     
  23.     time1=read clock
  24.     do
  25.         time2=read clock
  26.         time=time2-time1 
  27.         attempt to lock file
  28.     while file_is_locked_by_another_program and time<delay
  29.     
  30.     if time<delay then
  31.         remove file
  32.  
  33. The only way I can see that I can lock the file is to sopen it for read.  I must keep the file 
  34. opened (or else someone else can access it) until I have deleted it - that is the problem !
  35.  
  36. What I don't really want to do is to provide a critical error handler (unless I really have to) 
  37. Has anybody got any ideas ?
  38.  
  39. TIA.
  40.  
  41. -- 
  42. Steve Clarke            http://www.citynet.co.uk/users/trumpton
  43.  
  44. C is a programming language with all of the power of assembly language,
  45. and all the readability of assembly language.
  46.  
  47.